package study.apache.thrift.helloworld;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

public class Client {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// 传输层
		TTransport trans = new TSocket("localhost", 9090);

		// 协议层
		TProtocol prot = new TBinaryProtocol(trans);

		HelloWorld.Client client = new HelloWorld.Client(prot);

		try {
			// 传输打开
			trans.open();

			// 完成具体业务逻辑代码
			client.helloWorld();
			
		} catch (TTransportException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (TException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			// 传输关闭
			trans.close();
		}
	}

}
